package com.stud.seckill.common.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class R<T> {

    private Integer code;

    private String message;

    private T data;

    public R(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static <T> R<T> success() {
        return new R<>(200, "Success");
    }

    public static <T> R<T> success(T data) {
        return new R<>(200, "Success", data);
    }

    public static <T> R<T> fail() {
        return new R<>(500, "Fail");
    }

    public static <T> R<T> fail(String message) {
        return new R<>(500, message);
    }

    public static <T> R<T> fail(Integer code, String message) {
        return new R<>(code, message);
    }

}
